<cfcomponent output="false">
	
	<!--- --->
		
	<cffunction name="getFunds" access="public" output="false" returntype="query">
		<cfargument name="fundID" required="false" default="" />
		<cfargument name="city" required="false" default="" />
		<cfargument name="stateID" required="false" default="" />
		<cfargument name="email" required="false" default="" />
		<cfargument name="owner_name" required="false" default="" />
		<cfargument name="title" required="false" default="" />
		<cfargument name="description" required="false" default="" />
		<cfargument name="created_date" required="false" default="" />		
		
		<cfset var local = {} />
		
		<cfquery name="local.getFunds" datasource="fundrdb" cachedwithin="#createTimespan(0,0,0,2)#">
			select 
			fund.id,
			fund.amount,
			fund.title,
			fund.who,
			fund.description,
			fund.end_date,
			fund.private,
			user.city,
			user.state_id,
			state.abbrev as state,
			fund.created
			from fund
			inner join user on user.id = fund.user_id
				and user.active = 1
			left join state on state.id = user.state_id
			where fund.active = 1
			<cfif arguments.fundID neq ''>
				and fund.id = #application.q.queryID(arguments.fundID)#
			</cfif>
			<cfif arguments.city neq ''>
				and user.city like '%#arguments.city#%'
			</cfif>
			<cfif arguments.stateID neq ''>
				and user.state_id = #application.q.queryID(arguments.stateID)#
			</cfif>
			<cfif arguments.email neq ''>
				and user.email like '%#arguments.email#%'
			</cfif>
			<cfif arguments.owner_name neq ''>
				and user.first_name + ' ' + user.last_name like '%#arguments.owner_name#%'
			</cfif>
			<cfif arguments.title neq ''>
				and fund.title like '%#arguments.title#%'
			</cfif>
			<cfif arguments.description neq ''>
				and fund.description like '%#arguments.description#%'
			</cfif>
			<cfif arguments.created_date neq ''>
				<!--- todo finish date --->
				<!--- and fund.created_date  like '%#arguments.description#%' --->
			</cfif>
			order by fund.created desc
		</cfquery>

		<cfreturn local.getFunds />
		
	</cffunction>
	
	<!--- --->
	
</cfcomponent>